Imports DiceShenanigensUserControls

Public Class frmConfig

   Dim userType As userType

   Public Property setUser() As userType
      Get
         Return userType
      End Get
      Set(ByVal value As userType)
         userType = value
      End Set
   End Property

   Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
      Application.Exit()
   End Sub

   Private Sub LogoutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LogoutToolStripMenuItem.Click
      Me.Hide()
      frmStart.Show()
   End Sub

   Private Sub btnPlay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PlayToolStripMenuItem.Click

      FormGrid = New frmGrid(2, gameGridSize, Color.Aqua, Color.Tomato)
      Me.Hide()
      FormGrid.Show()

   End Sub

   Private Sub frmConfig_Shown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Shown

      If userType = userType.PvE Then

         Label8.Text = "Your color:"
         pnlConfig.Height = 216
         pnlStats.Height = 216
         Me.Height = 297

      Else

         Label8.Text = "Player one's color:"
         pnlConfig.Height = 264
         pnlStats.Height = 264
         Me.Height = 345

      End If

   End Sub

   Private Sub frmConfig_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

      Dim dbUser As User = getUserData(Username)

      lblPlayer.Text = dbUser.FirstName & " " & dbUser.LastName
      Wins.Text = dbUser.Wins
      Losses.Text = dbUser.Losses

      If (dbUser.Wins / dbUser.GamesPlayed).ToString = "NaN" Then
         Average.Text = 0.0
      Else
         Average.Text = Convert.ToDouble(dbUser.Wins / dbUser.GamesPlayed)
      End If

   End Sub

   Private Sub CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sizeSmall.CheckedChanged, SizeMedium.CheckedChanged, sizeLarge.CheckedChanged

      If sizeSmall.Checked = True Then
         gameGridSize = GridSize.Small
      ElseIf SizeMedium.Checked = True Then
         gameGridSize = GridSize.Medium
      ElseIf sizeLarge.Checked = True Then
         gameGridSize = GridSize.Large
      Else
         MsgBox("ERROR IN GRID SIZE RADIO BOX SETTING!!")
      End If

   End Sub

End Class